<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Access
 *
 * @author zxcms
 */
class Henry_Access extends Zend_Db_Table_Abstract
{
    protected $_name = '' ;
    protected $_primary = 'session_id';

    public function __construct() {
        parent::__construct();
        $dbconfig = $this->_db->getConfig();
        $this->_name = $dbconfig['prefix'].'access';
    }

    public function add($session_id){
        $find = $this->find($session_id)->toArray();
        if (count($find)>0){
            $data = array(
              'timeacess' => time(),
            );
            $where = $this->_db->quoteInto("session_id = ?", $session_id);
            $this->update($data, $where);
        }else{
             $data = array(
              'timeacess' => time(),
                 'session_id' => $session_id,
            );
             $this->insert($data);
        }
    }
    public function countAccess(){
        $select = $this->_db->select();
        $select->from($this->_name,array('count'=>new Zend_Db_Expr('count(*)')));
        return $this->_db->fetchOne($select)+5000;
    }
}
?>
